{% extends 'base.html' %}

{% block title %}{{ title }} - 多用户报警系统{% endblock %}

{% block content %}
<div class="container main-container">
    <div class="row mb-4">
        <div class="col-lg-12">
            <h1 class="page-title">{{ title }}</h1>
        </div>
    </div>
    
    <div class="row mb-4">
        <div class="col-lg-8 offset-lg-2">
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">{{ title }}</h3>
                </div>
                
                <div class="card-body">
                    <div class="alert alert-warning" role="alert">
                        <i class="fa fa-exclamation-triangle"></i> 警告：删除操作不可逆，确定要删除此任务执行日志吗？
                    </div>
                    
                    <div class="mb-4">
                        <h4>任务执行日志详情</h4>
                        <table class="table table-bordered">
                            <tbody>
                                <tr>
                                    <th>任务名称</th>
                                    <td>{{ log.task.name }}</td>
                                </tr>
                                <tr>
                                    <th>开始时间</th>
                                    <td>{{ log.start_time|date:"Y-m-d H:i:s" }}</td>
                                </tr>
                                <tr>
                                    <th>结束时间</th>
                                    <td>
                                        {% if log.end_time %}
                                            {{ log.end_time|date:"Y-m-d H:i:s" }}
                                        {% else %}
                                            - 
                                        {% endif %}
                                    </td>
                                </tr>
                                <tr>
                                    <th>持续时间</th>
                                    <td>
                                        {% if log.duration %}
                                            {{ log.duration }}秒
                                        {% else %}
                                            - 
                                        {% endif %}
                                    </td>
                                </tr>
                                <tr>
                                    <th>执行状态</th>
                                    <td>
                                        {% if log.is_success %}
                                            <span class="badge badge-success">成功</span>
                                        {% else %}
                                            <span class="badge badge-danger">失败</span>
                                        {% endif %}
                                    </td>
                                </tr>
                                <tr>
                                    <th>错误信息</th>
                                    <td>{{ log.error_message|default:"无" }}</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    
                    <form method="post">
                        {% csrf_token %}
                        <div class="form-group text-center">
                            <button type="submit" class="btn btn-danger">
                                <i class="fa fa-trash"></i> 确认删除
                            </button>
                            <a href="{% url 'tasks:task_execution_logs' %}" class="btn btn-secondary ml-2">
                                <i class="fa fa-times"></i> 取消
                            </a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}